#include<windows.h> 
#include <math.h>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
typedef struct BiNode{				
	char data;
	struct BiNode *lchild,*rchild;
}BiTNode,*BiTree;
void CreateBiTree(BiTree &T){	
	
	char ch;
	scanf("%c",&ch);
	if(ch=='#')  T=NULL;			
	else{							
		T=new BiTNode;
		T->data=ch;					
		CreateBiTree(T->lchild);	
		CreateBiTree(T->rchild);	
	}								//else
}									//CreateBiTree
void gotoxy(int x, int y) { 
	COORD c; 
	c.X = x -1; 
	c.Y = y -1; 
	SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c); 
} 

void DisplayBinTree(BiTree T,int col,int row,int h) 
{ 
	if (T)
	{ gotoxy(col,row);
		printf("%c",T->data);
		DisplayBinTree(T->lchild,col-h,row+1,h/2);
		DisplayBinTree(T->rchild,col+h,row+1,h/2);
	}
}
int GetHightOfTree(BiTree T)
{
	int rh=0,lh=0;
	if(!T)
		return 0;		
	else
	{
		lh=GetHightOfTree(T->lchild);
		rh=GetHightOfTree(T->rchild);
		return (lh>rh?lh:rh)+1;
	}
}
void DisplayTree(BiTree T)
{
	int k=0;
	k=GetHightOfTree(T);
	DisplayBinTree(T, (int)(pow(2,k-1)*2+1),4,(int)pow(2,k-1)) ;
	printf("\n\n\n\n\n\n\n");
}
void printNode(BiTree T){
	if(T==NULL) return;
	if(T->lchild!=NULL&&T->rchild!=NULL)
		printf("%c ",T->data);
	printNode(T->lchild);
	printNode(T->rchild);
	
}
char max_n(char a,char b){
	return a>b?a:b;
}
char getMax(BiTree T){
	if(T==NULL) return T->data;
			
}
int main(){
    BiTree tree;
    printf("输入先序序列：\n");
    CreateBiTree(tree);
    // DisplayTree(tree);
	// system("pause");
	// printNode(tree);
	printf("\n最大的结点的值为：%c\n",getMax(tree));
    return 0;
}